import type { PageData } from "#/axios"

enum TemplateStatus {
  Normal,
  InUse,
  Deregistered
}

// 0-会员卡，1-优惠券，2-电票(现在传 0)
type PassType = 0 | 1 | 2
export type PKBarcodeFormat =
'PKBarcodeFormatQR' |
'PKBarcodeFormatPDF417' |
'PKBarcodeFormatAztec' |
'PKBarcodeFormatCode128'

export interface PKField {
  key: string  
  label: string
  changeMessage: string
}

export interface PKBeacon {
  major: number,
  minor: number
  proximityUUID: string
  relevantText: string
}

export interface PKBarcode {
  format: PKBarcodeFormat
  altText: string
  message: string
  messageEncoding: string
}

export interface Location {
  latitude: number
  longitude: number
}

export interface TemplateInfo {
  auxiliaryFields: PKField[]
  backFields: PKField[]
  backgroundColor: string
  barcodes: PKBarcode[]
  beacons: PKBeacon[]
  description: string
  headerFields: PKField[]
  iconUrl: string
  labelColor: string
  locations: string
  logoText: string
  logoUrl: string 
  primaryFields: PKField[]
  secondaryFields: PKField[]
  stripUrl: string
  tempUuid: string
  textColor: string
  passTypeIdentifier: string
}

export interface PassTemplate {
  passTypeIdentifier: string
  passType: PassType
  passChannel: 'APPLE' // 现在默认传 APPLE
  tempType: 0
  tempName: string
  backgroundColor: string
  description: string
  textColor: string
  labelColor: string
  thumbUuid: string | null
  iconUuid: string | null
  logoUuid: string | null
  stripUuid: string | null
  logoText: string
  headerFields: PKField[]
  primaryFields: PKField[]
  secondaryFields: PKField[]
  backFields: PKField[]
  auxiliaryFields?: PKField[]
  barcodes: PKBarcode[] | null
  locations: Location[]
  characterCode?: string
  keyId: number
  nfcKeyId: number | null,
  keyName: string
  key?: string
  associatedStoreIdentifier: number
  webServiceURL: string
  creUserId?: number,
  beacons: PKBeacon[]  
  remark: string
  topicId: number | null
  templateLevel: number | null
}
export interface SettingsField {
  templateName: string
  description: string
  timezone: string
  defaultLanguage: string,
  remark: string
  passTypeIdentifier: string,
  nfcKeyId: number
}

export interface TemplateListRequest {
  passTypeIdentifier?: string
  tempName?: string
  mrchName?: string
  status?: number
  pageNo: number
  pageSize: number
}

export interface TemplateData {
  tempName: string
  tempUuid: number
  mrchName: string
  thumbUrl: string
  status: TemplateStatus
  tempCreateTime: number
  tempUpdateTime: number
}

export interface TemplateListResponse {  
  data: TemplateData[]
}

export interface PassIdentifierResponse extends PageData {
  data: PassIdentifier[]
}

export interface PassIdentifier {
  id: number
  passTypeId: string
  creTime: number
  status: number
  description: string
}